package com.hstcs.screen;

import javafx.scene.shape.MoveTo;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.scenes.scene2d.Action;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.*;
import com.badlogic.gdx.scenes.scene2d.actions.MoveToAction;
import com.badlogic.gdx.scenes.scene2d.actions.SequenceAction;
import com.badlogic.gdx.scenes.scene2d.ui.Button;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.Align;
import com.hstcs.assets.Assets;
import com.hstcs.assets.Config;
import com.hstcs.assets.FileName;
import com.hstcs.game.XGame;
import com.hstcs.ui.HLabel;

public class MainMenuScreen implements Screen {
	
	public static MainMenuScreen instance =null;
	
	public static MainMenuScreen getInstance()
	{
		if(instance == null){
			instance = new MainMenuScreen();
		}
		return  instance;
	}
	private Stage stage = null;
	private Image bg = null;
	private  boolean init = false;
	
	private Button startButton;

	
	public void initActor(){
		if(init == true) return;
		init = true;
		bg = new Image((Texture)Assets.get(FileName._BG_START));
		bg.setFillParent(true);
		
		startButton = new Button(Assets.skin, "startbtn");
		startButton.setOrigin(Align.center);
		listen();
	}
	@Override
	public void render(float delta) {
		// TODO Auto-generated method stub
		stage.act();
		stage.draw();
	}

	@Override
	public void resize(int width, int height) {
		// TODO Auto-generated method stub

	}

	@Override
	public void show() {
		// TODO Auto-generated method stub
		stage = XGame.getInstance().stage;
		stage.clear();
		initActor();
		
		startButton.setPosition(Config._WIDTH/2 - startButton.getWidth()/2, 
				90);
		
		stage.addActor(bg);
		stage.addActor(startButton);
		
		Gdx.input.setInputProcessor(stage);
		
	}

	@Override
	public void hide() {
		// TODO Auto-generated method stub

	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub

	}

	@Override
	public void resume() {
		// TODO Auto-generated method stub

	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub

	}
	
	
	public void listen()
	{
		startButton.addListener(new ClickListener(){
			@Override
			public void clicked(InputEvent event, float x, float y) {
				super.clicked(event, x, y);
				XGame.getInstance().setScreen(new GameScreen());

			};
		
		});
	}

}
